#include<bits/stdc++.h>
using namespace std;
// 计算年份 要区分闰年

int main(){
	int year,mon,day;
	int days[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
	while(scanf("%d/%d/%d",&year,&mon,&day) != EOF){
		int res = 0;
		if((year % 4 == 0 &&  year % 100 != 0) || year % 400 == 0){
			days[1] = 29; 
		}else{
			days[1] = 28;
		}	
		
		for(int i=0;i< mon -1;i++){
			res += days[i];
		}
		res += day;
		cout << res << endl;
	}	
	return 0;
}
